package com.orange.lswidget.widgets.event.dao;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.content.Context;
import android.database.Cursor;

import com.orange.notificationsummary.event.pil.defaultimpl.BaseEvent;
import com.orange.util.LogHelper;

public class VoiceMailDao extends DaoHelper {
	private static final String	TAG	= "VoiceMailDao";

	public VoiceMailDao(Context context) {
		super(context);
	}

	public List<Map<String, String>> queryAllVoiceMailToList() {
		Cursor cursor = mNotificationInterfc.getVoiceMailCursor(mContext);

		List<Map<String, String>> list = new ArrayList<Map<String, String>>();
		if (cursor != null) {
			try {
				while (cursor.moveToNext()) {
					Map<String, String> vvmMap = new HashMap<String, String>();
					int count = cursor.getColumnCount();
					for (int i = 0; i < count; i++) {
						String columnName = cursor.getColumnName(i);
						String columnValue = cursor.getString(i);
						vvmMap.put(columnName, columnValue);
					}
					list.add(vvmMap);
				}
			} catch (Exception e) {
				LogHelper.e(TAG, "queryAllVoiceMailToList. ", e);
			} finally {
				cursor.close();
			}
		}

		return list;
	}

	public List<BaseEvent> queryVoiceMailList() {
		return mNotificationInterfc.getVoiceMailList(mContext);
	}

}
